﻿using System;
using System.Numerics;
class FactorialEquation
{
    static void Main()
    {
        int numberN;
        int numberK;
        BigInteger factn = 1;
        BigInteger factk = 1;
        BigInteger factkn = 1;
        Console.WriteLine("Please enter K and N, K > N");
        do
        {
            while (true)
            {
                try
                {
                    numberK = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number:");
                }
            }
            while (true)
            {
                try
                {
                    numberN = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number:");
                }
            }
        } while ((numberN < 1) || (numberK < numberN));
        Console.WriteLine("1, {0}, {1}", numberK, numberN);
        Console.ReadLine();
        for (int i = 1; i <= numberK; i++)
        {
            factk = factk * i;
        }
        for (int i = 1; i <= numberN; i++)
        {
            factn = factn * i;
        }
        for (int i = 1; i <= (numberK - numberN); i++)
        {
            factkn = factkn * i;
        }
        Console.WriteLine("Factorial of {0} is: {1}", numberK, factk);
        Console.WriteLine("Factorial of {0} is: {1}", numberN, factn);
        Console.WriteLine("Factorial of {0}-{1} is: {2}", numberK, numberN, factkn);
        Console.WriteLine("Result of {0}!*{1}!/({1}-{0})! is: {2}", numberN, numberK, ((factn * factk) / factkn));
        Console.ReadLine();
    }
}

